package com.wgchao.authmanager.domain.model;

import com.wgchao.authmanager.infrastructure.exception.ObjectNotMatchingException;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @ClassName: RoleIdentity
 * @author: wgchao
 * @createTime: 2020/4/26 11:08 AM
 * @Description: TODO
 */
@AllArgsConstructor
@Getter
public class RoleIdentity extends ValueObject {
    private String agencyCode;
    private String roleName;

    protected void assertBelongTo(Agency agency){
        if(!this.agencyCode.equals(agency.getAgencyCode())){
            throw new ObjectNotMatchingException(this.roleName+"角色不属于机构"+agency.getAgencyName());
        }
    }
}
